package com.itheima.git练习;

import java.util.Arrays;

/**
 * @Author chris
 * @Date 2020/6/13 15:57
 */
public class Demo {
    public static void main(String[] args) {
        //选择排序
        int []arr={12,4,5,3,2,23,7,5,44,332,2,445,66};
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = i+1; j < arr.length; j++) {
                if(arr[i]>arr[j]){
                    int a=arr[i];
                    arr[i]=arr[j];
                    arr[j]=a;
                }


            }

        }
        for (int i1 : arr) {
            System.out.print(i1 + " ");

        }
        //冒泡排序
        int[]arr1={12,3443,2,2,2,266,7,8,8,65,0,43,2,45};
        for (int i = 0; i < arr1.length-1; i++) {
            for (int j = 0; j < arr1.length-1-i; j++) {
                if(arr1[j]>arr1[j+1]){
                    int a=arr1[j];
                    arr1[j]=arr1[j+1];
                    arr1[j+1]=a;
                }
            }

        }
        System.out.println();
        System.out.println(Arrays.toString(arr1));
    }
}
